package com.luoha.test;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;

import com.luoha.excel.ExcelHandler;
import com.luoha.lottery.Employee;

public class Client {
	
	public static void sendRequest(String empId,String empName){
		HttpRequest.sendGet("http://localhost:8080/lottery/lottery?action=lottery&empId="+empId+"&empName="+empName, "");
	}

	public static void main(String[] args) {
		List<Employee> employeeList = new ArrayList<Employee>();
		try {
			String path = Thread.currentThread().getContextClassLoader().getResource("").toURI().getPath();
			path += "resources/员工名单.xlsx";
			ExcelHandler excelHandler = new ExcelHandler();
			employeeList = excelHandler.readExcel(path);
		}catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (URISyntaxException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		for(Employee emp : employeeList){
//			System.out.println(emp.getEmpId());
			Thread t = new Client().new MyThread(emp.getEmpId(),emp.getEmpName());
			t.start();
		}
	}
	
	class MyThread extends Thread{
		private String empId;
		private String empName;
		public MyThread(String empId,String empName) {
			this.empId = empId;
			this.empName = empName;
		}
		@Override
		public void run() {
			Client.sendRequest(empId,empName);
		}
	}

}
